import React, { Component } from 'react'
import { Icon, Button, Table, Switch, Form, Input, Modal,Row,Col } from 'antd'

const FormItem = Form.Item;

class AddQuestionInput extends Component {
  constructor(props) {
    super(props);
    this.handleSubmit = this.handleSubmit.bind(this)
     this.state = {
      visible: false,
      loading: false
    }
    this.showModal=this.showModal.bind(this)
    this.handleOk=this.handleOk.bind(this)
    this.handleCancel=this.handleCancel.bind(this)
  }
  handleSubmit(e) {
    e.preventDefault();
    this.props.form.validateFields((err, values) => {
      if (err) {
        return;
      }
      console.log(this.props.termsId);
      this.props.addOneQuestion({
        _creator:this.props.termsId,
        questions_name:values.name
      })
      
    });
  }
  showModal() {
    this.setState({
      visible: true,
    });
  }
  handleOk() {
    this.setState({ loading: true });
    setTimeout(() => {
      this.setState({ loading: false, visible: false });
    }, 3000);
  }
  handleCancel() {
    this.setState({ visible: false });
  }
  render() {
    const { getFieldDecorator } = this.props.form;
     const formItemLayout = {
      labelCol: { span: 5 },
      wrapperCol: { span: 19 },
    };
    return (
      <div>
        <Form  onSubmit={this.handleSubmit}>
        <Row gutter={16}>
            <Col className="gutter-row" span={6}>
             <FormItem  {...formItemLayout} label='条目' >
                  {getFieldDecorator('name', {
                    rules: [{ required: true, message: '请输入一个条目' }],
                  })(
                    <Input  placeholder="请输入条目名称"  rows={4} />
                  )}
                </FormItem>
            </Col>

            <Col className="gutter-row" span={6}>
                <FormItem  >
                  <Button type="primary" htmlType="submit" > 添加</Button>
                </FormItem>
            </Col>
           
          </Row>
        
        
       
        </Form>

      </div>

    );
  }
}


AddQuestionInput = Form.create()(AddQuestionInput)
export default AddQuestionInput
